/**
 * 	this is the Supervisor Panel
 */


package gui;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JButton;

import common.ChatIF;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.ArrayList;

public class SupervisorPanel extends JPanel {
	AcademicFrame frame;
	AssessorPanel assessor;
	MainWindow mainWindow;
	SupervisorPanel supervisorPanel;
	private String userID;
	
	public SupervisorPanel(AcademicFrame frame, MainWindow mainWindow, boolean supervisor, String userID ) {
		super();
		this.frame=frame;
		this.mainWindow=mainWindow;
		this.userID = userID;
		this.supervisorPanel=this;
		frame.setSize(500, 400);
		initialize();
		
	}
	
	private void initialize() {
		setLayout(null);
		
		JLabel lblSupervisor = new JLabel("Supervisor");
		lblSupervisor.setForeground(Color.BLUE);
		lblSupervisor.setFont(new Font("Tahoma", Font.BOLD, 28));
		lblSupervisor.setBounds(151, 29, 150, 28);
		add(lblSupervisor);
		
		JButton btnApproveAssessDuration = new JButton("Approve Assess\r\n Duration");
		btnApproveAssessDuration.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				frame.setContentPane(new ApproveAssessDurationPanel(frame, supervisorPanel));
				frame.setSize(460, 420);
				
				ArrayList<Object> req= new ArrayList<Object>();
				req.add("getReq");
				req.add("3");
				AcademicFrame.myclient.sendMessageToServer(req); // get requests
			}
		});
		btnApproveAssessDuration.setBounds(239, 84, 179, 23);
		add(btnApproveAssessDuration);
		
		JButton btnManageRequest = new JButton("Manage request");
		btnManageRequest.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane(new ManageRequestPanel(frame, supervisorPanel,true, userID));
				frame.setSize(460, 420);
			}
		});
		btnManageRequest.setBounds(239, 175, 179, 23);
		add(btnManageRequest);
		
		JButton btnAssessorPairing = new JButton("Assessor Pairing");
		btnAssessorPairing.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				frame.setContentPane(new AssessorPairingPanel(frame, supervisorPanel));
				frame.setSize(460, 320);
			
				ArrayList<Object> req= new ArrayList<Object>();
				req.add("getReq");
				req.add("1");
				AcademicFrame.myclient.sendMessageToServer(req); // get requests
			
			
				
			}
		});
		btnAssessorPairing.setBounds(37, 84, 177, 23);
		add(btnAssessorPairing);
		
		JButton btnApproveExecution = new JButton("Approve Extention");
		btnApproveExecution.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane(new ApproveExtentionPanel(frame, supervisorPanel));
				frame.setSize(460, 420);
				
				ArrayList<Object> extend= new ArrayList<Object>();
				extend.add("getExtend");
				AcademicFrame.myclient.sendMessageToServer(extend); // get requests
			}
		});
		btnApproveExecution.setBounds(37, 175, 177, 23);
		add(btnApproveExecution);
		
		JButton btnApproveExecutionDuration = new JButton("Approve Execution Duration");
		btnApproveExecutionDuration.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane(new ApproveExecutionDurationPanel(frame, supervisorPanel));
				frame.setSize(460, 420);
				
				ArrayList<Object> req= new ArrayList<Object>();
				req.add("getReq");
				req.add("9");
				AcademicFrame.myclient.sendMessageToServer(req); // get requests
			}
		});
		btnApproveExecutionDuration.setBounds(231, 129, 197, 23);
		add(btnApproveExecutionDuration);
		
		JButton btnBack = new JButton("Back");
		btnBack.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setSize(500, 500);
				frame.setContentPane(mainWindow);
			}
		});
		btnBack.setBounds(185, 282, 89, 23);
		add(btnBack);
		
		JButton btnELP = new JButton("Execution Leader Pairing");
		btnELP.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

				frame.setContentPane(new ExecutionLeaderPairingPanel(frame, supervisorPanel));
				frame.setSize(460, 420);
			
				ArrayList<Object> requests= new ArrayList<Object>();
				requests.add("getReq");
				requests.add("7");
		
				AcademicFrame.myclient.sendMessageToServer(requests);
				
			}
		});
		btnELP.setBounds(37, 129, 179, 23);
		add(btnELP);
		
		JButton btnComplete = new JButton("Complete Request");
		btnComplete.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane(new CompleteRequestPanel(frame, supervisorPanel));
				frame.setSize(460, 420);
				
				ArrayList<Object> completeReq= new ArrayList<Object>();
				completeReq.add("completeReq");
				completeReq.add("62");
				completeReq.add("121");
				AcademicFrame.myclient.sendMessageToServer(completeReq); // get requests
			}
		});
		btnComplete.setBounds(37, 222, 177, 23);
		add(btnComplete);
		
		JButton btnSuspendResume = new JButton("Suspend & Resume");
		btnSuspendResume.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				frame.setContentPane(new SuspendResumePanel(frame, supervisorPanel));
				frame.setSize(460, 420);
				
				ArrayList<Object> req= new ArrayList<Object>();
				req.add("getAllReq");
				AcademicFrame.myclient.sendMessageToServer(req); // get requests
			}
		});
		btnSuspendResume.setBounds(245, 222, 173, 23);
		add(btnSuspendResume);
	}
}


